package com.itheima.job;

import java.util.LinkedHashSet;

public class Test09 {
    public static void main(String[] args) {
        LinkedHashSet<Student2> lhs = new LinkedHashSet<>();
        lhs.add(new Student2(100,"小红",20,"女"));
        lhs.add(new Student2(100,"小明",20,"男"));
        lhs.add(new Student2(101,"小明",23,"男"));
        System.out.println(lhs);
    }
}

//标准Student类
class Student2{
    private int num;//学号
    private String name;//姓名
    private String gender;//性别
    private int age;//年龄
    public Student2() {}
    public Student2(int num, String name, int age, String gender) {
        this.num = num;
        this.name = name;
        this.gender = gender;
        this.age = age;
    }
    public int getNum() {
        return num;
    }
    public void setNum(int num) {
        this.num = num;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getGender() {
        return gender;
    }
    public void setGender(String gender) {
        this.gender = gender;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    @Override
    public String toString() {
        return "Student [num=" + num + ", name=" + name + ", gender=" + gender + ", age=" + age + "]";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Student2 student2 = (Student2) o;

        return num == student2.num;
    }

    @Override
    public int hashCode() {
        return num;
    }
}
